﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Device.aspx.cs" Inherits="Mercator2.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div _designerregion="0">
    <div _designerregion="0">
        Cadastro de Dispositivos Embarcados<br />
        Digite um código de dispositivo:
        <asp:TextBox ID="txtDeviceID" runat="server"></asp:TextBox>
&nbsp;<asp:Button ID="btnSearch" runat="server" onclick="btnSearch_Click" 
            Text="Procurar por número do dispositivo" Width="223px" />
        <br />

    <asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" 
        DataSourceID="Mercator" Height="50px" Width="335px" 
        AutoGenerateRows="False" DataKeyNames="DeviceID" BackColor="White" 
        BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" 
        GridLines="Horizontal" style="background-color: #0066FF" 
            ondatabound="DetailsView1_DataBound">
        <AlternatingRowStyle BackColor="#F7F7F7" />
        <EditRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
        <Fields>
            <asp:BoundField DataField="DeviceID" HeaderText="Nr. Dispositivo" ReadOnly="True" 
                SortExpression="DeviceID" />
            <asp:BoundField DataField="SIMchipPhoneNumber" HeaderText="Número do Chip SIM" 
                SortExpression="SIMchipPhoneNumber" />
            <asp:BoundField DataField="VRN" HeaderText="Placa veículo" 
                SortExpression="VRN" />
            <asp:BoundField DataField="VIN" HeaderText="RENAVAM" SortExpression="VIN" />
            <asp:BoundField DataField="ServerIP" HeaderText="IP servidor" 
                SortExpression="ServerIP" />
            <asp:BoundField DataField="DeviceIP" HeaderText="IP dispositivo" 
                SortExpression="DeviceIP" />
            <asp:BoundField DataField="SMSManagementNumber" 
                HeaderText="Tel. gestor" SortExpression="SMSManagementNumber" />
            <asp:BoundField DataField="LastLongitude" HeaderText="Longitude atual" 
                SortExpression="LastLongitude" />
            <asp:BoundField DataField="LastLatitude" HeaderText="Latitude atual" 
                SortExpression="LastLatitude" />
            <asp:BoundField DataField="LastSpeed" HeaderText="Velocidade atual" 
                SortExpression="LastSpeed" />
            <asp:BoundField DataField="LastMileage" HeaderText="Odometro" 
                SortExpression="LastMileage" />
            <asp:BoundField DataField="LastUploadDate" HeaderText="Data última atualização" 
                SortExpression="LastUploadDate" />
            <asp:BoundField DataField="LastUploadTime" HeaderText="Hora última atualização" 
                SortExpression="LastUploadTime" />
            <asp:BoundField DataField="GroupID" HeaderText="Código do Grupo" 
                SortExpression="GroupID" />
            <asp:CommandField CancelText="Cancelar" DeleteText="Excluir" EditText="Editar" 
                InsertText="Inserir" NewText="Novo" SelectText="Selecionar" 
                ShowDeleteButton="True" ShowEditButton="True" ShowHeader="True" 
                ShowInsertButton="True" UpdateText="Atualizar" />
        </Fields>
        <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
        <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
        <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" 
            VerticalAlign="Middle" />
        <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
    </asp:DetailsView>

    <asp:SqlDataSource ID="Mercator" runat="server" 
        ConnectionString="<%$ ConnectionStrings:MERCATOR_histConnectionString %>" 
        DeleteCommand="DELETE FROM [Device] WHERE [DeviceID] = @DeviceID" 
        InsertCommand="INSERT INTO [Device] ([DeviceID], [VRN], [VIN], [ServerIP], [DeviceIP], [SMSManagementNumber], [LastLongitude], [LastLatitude], [LastSpeed], [LastMileage], [LastUploadDate], [LastUploadTime], [ServerPort], [GroupID], [TotalBytesReceivedDay], [TotalBytesReceivedMonth]) VALUES (@DeviceID, @VRN, @VIN, @ServerIP, @DeviceIP, @SMSManagementNumber, @LastLongitude, @LastLatitude, @LastSpeed, @LastMileage, @LastUploadDate, @LastUploadTime, @ServerPort, @GroupID, @TotalBytesReceivedDay, @TotalBytesReceivedMonth)" 
        SelectCommand="SELECT * FROM [Device]" 
        
        
        
            UpdateCommand="UPDATE [Device] SET [VRN] = @VRN, [VIN] = @VIN, [ServerIP] = @ServerIP, [DeviceIP] = @DeviceIP, [SMSManagementNumber] = @SMSManagementNumber, [LastLongitude] = @LastLongitude, [LastLatitude] = @LastLatitude, [LastSpeed] = @LastSpeed, [LastMileage] = @LastMileage, [LastUploadDate] = @LastUploadDate, [LastUploadTime] = @LastUploadTime, [ServerPort] = @ServerPort, [GroupID] = @GroupID, [TotalBytesReceivedDay] = @TotalBytesReceivedDay, [TotalBytesReceivedMonth] = @TotalBytesReceivedMonth WHERE [DeviceID] = @DeviceID">
        <DeleteParameters>
            <asp:Parameter Name="DeviceID" Type="String" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="DeviceID" Type="String" />
            <asp:Parameter Name="VRN" Type="String" />
            <asp:Parameter Name="VIN" Type="String" />
            <asp:Parameter Name="ServerIP" Type="String" />
            <asp:Parameter Name="DeviceIP" Type="String" />
            <asp:Parameter Name="SMSManagementNumber" Type="String" />
            <asp:Parameter Name="LastLongitude" Type="String" />
            <asp:Parameter Name="LastLatitude" Type="String" />
            <asp:Parameter Name="LastSpeed" Type="String" />
            <asp:Parameter Name="LastMileage" Type="String" />
            <asp:Parameter Name="LastUploadDate" Type="String" />
            <asp:Parameter Name="LastUploadTime" Type="String" />
            <asp:Parameter Name="ServerPort" Type="String" />
            <asp:Parameter Name="GroupID" Type="String" />
            <asp:Parameter Name="TotalBytesReceivedDay" Type="Int32" />
            <asp:Parameter Name="TotalBytesReceivedMonth" Type="Int32" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="VRN" Type="String" />
            <asp:Parameter Name="VIN" Type="String" />
            <asp:Parameter Name="ServerIP" Type="String" />
            <asp:Parameter Name="DeviceIP" Type="String" />
            <asp:Parameter Name="SMSManagementNumber" Type="String" />
            <asp:Parameter Name="LastLongitude" Type="String" />
            <asp:Parameter Name="LastLatitude" Type="String" />
            <asp:Parameter Name="LastSpeed" Type="String" />
            <asp:Parameter Name="LastMileage" Type="String" />
            <asp:Parameter Name="LastUploadDate" Type="String" />
            <asp:Parameter Name="LastUploadTime" Type="String" />
            <asp:Parameter Name="ServerPort" Type="String" />
            <asp:Parameter Name="GroupID" Type="String" />
            <asp:Parameter Name="TotalBytesReceivedDay" Type="Int32" />
            <asp:Parameter Name="TotalBytesReceivedMonth" Type="Int32" />
            <asp:Parameter Name="DeviceID" Type="String" />
        </UpdateParameters>
    </asp:SqlDataSource>
</div>
</div>
</asp:Content>
